#!/bin/bash
#****CentOS6开放对应的防火墙**************#
IPT="/sbin/iptables"

$IPT -F
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT DROP

$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

$IPT -A INPUT -p tcp --dport 22 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 22 -j ACCEPT

$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

#$IPT -A INPUT -p icmp -j ACCEPT 禁止Ping服务器
$IPT -A OUTPUT -p icmp -j ACCEPT

$IPT -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
#$IPT -A INPUT -p udp -m udp --sport 53 -j ACCEPT

$IPT -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
$IPT -A INPUT -p tcp --dport 80 -j ACCEPT

$IPT -A INPUT -p tcp --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp --dport 10020:10040 -j ACCEPT

$IPT -A OUTPUT -p udp --dport 123 -j ACCEPT

#$IPT -A INPUT -j REJECT --reject-with icmp-host-prohibited
#$IPT -A FORWARD -j REJECT --reject-with icmp-host-prohibited

$IPT -A OUTPUT -p tcp -m tcp --dport 9200 -j ACCEPT
$IPT -A INPUT -p tcp --dport 9200 -j ACCEPT

$IPT -A OUTPUT -p tcp -m tcp --dport 9300 -j ACCEPT
$IPT -A INPUT -p tcp --dport 9300 -j ACCEPT

service iptables save
service iptables restart